build(tsconfig): scope type lib to Node 22 features - #151
Merged
Conversation
Bump target to ES2024 and set an explicit lib so the TypeScript type library matches what Node 22 (V8 12.4) ships at runtime: Object.groupBy / Map.groupBy and Promise.withResolvers (ES2024), Set methods and iterator helpers (ES2025 Collection/Iterator sublibs), and Array.fromAsync (ESNext.Array). Granular sublibs are used on purpose so Float16Array, which is Node 24, stays out. https://claude.ai/code/session_01PazNrvKYZSS5eYu9DUGurf
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Bump
targettoES2024and set an explicitlibinconfigs/base.jsonso the TypeScript type library matches what Node 22 (V8 12.4) ships at runtime.Why
The project runs on Node 22 (CI and
enginesalready pin it), buttargetwasES2022with nolib, so the type library stopped at ES2022. Node 22 language built-ins did not typecheck even though they run fine. As the linked DefinitelyTyped discussion notes, language built-ins come from TypeScript'slib, not@types/node.Feature to lib mapping (TypeScript 6.0.3):
toSorted/toReversed/withObject.groupBy/Map.groupBy,Promise.withResolversunion/intersection/difference/ …)map/filter/take/toArray/ …)Array.fromAsyncOnly Node 22, nothing beyond
The granular sublibs are deliberate. The full
ES2025lib would also pull inFloat16Array(Node 24), andESNext.Collectionwould pull inMap.getOrInsert(a Stage-3 proposal, not in Node 22). Both are excluded by this config. Verified:new Float16Array(2)→error TS2304: Cannot find name 'Float16Array'.new Map().getOrInsert("a", 1)→error TS2550: Property 'getOrInsert' does not exist.Verify
Both pass;
pnpm formatandpnpm lintare clean.Ref: DefinitelyTyped/DefinitelyTyped#74504
https://claude.ai/code/session_01PazNrvKYZSS5eYu9DUGurf
Generated by Claude Code